package br.ufms.facom.locadora.ws.util;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.ComponentFactory;
import java.sql.Connection;
import java.sql.DriverManager;

@Component
public class ConnectionFactory implements ComponentFactory<Connection> {
    private static final String ADDRS = "localhost";
    
    @Override
    public Connection getInstance() {
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://"+ADDRS+"/prof","prof","prof");
            
            return conn;
        }
        catch(Exception ex)
        {            
            throw new RuntimeException("Falha na abertura do banco de dados!", ex);
        }   
    }
}
